@extends('layout.master')

@section('title','修改话题')

@section('css')
    @parent
    <link href="{{ asset('plugins/bower_components/summernote/dist/summernote.css') }}" rel="stylesheet"/>
    <!-- animation CSS -->
    <link href="{{ asset('css/animate.css') }}" rel="stylesheet">
    <link href="{{ asset('plugins/bower_components/icheck/skins/all.css') }}" rel="stylesheet">
    <link href="{{ asset('plugins/bower_components/bootstrap-switch/bootstrap-switch.min.css') }}" rel="stylesheet">
@endsection
@section('main')

    @if (session('message'))
        <div>
            <input type="hidden" id="hidden" name="hidden" value="hidden">
            <input type="hidden" id="message" name="message" value="{{ session('message') }}">
            <input type="hidden" id="status" name="status" value="{{ session('status') }}">
        </div>
    @endif

    <div class="row">

        <div class="col-lg-12 col-md-12">
            <div class="white-box">
                <form class="form-horizontal form-material" id="modify" method="post" enctype="multipart/form-data">
                    <div class="row">
                        <div class="col-md-12 col-sm-8">
                            <div class="row">
                                <div class="col-md-2 col-sm-6">
                                    <div class="form-group">
                                        <label class="col-md-12">名称</label>
                                        <div class="col-md-12">
                                            <input type="text" name="title" value="{{ $huati->title }}"
                                                   class="form-control form-control-line" required>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-4 col-sm-6">
                                    <div class="form-group">
                                        <label class="col-md-12">小标题</label>
                                        <div class="col-md-12">
                                            <input type="text" name="title2" value="{{ $huati->title2 }}"
                                                   class="form-control form-control-line" required>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-2 col-sm-4">
                                    <div class="form-group">
                                        <label class="col-md-12">排序</label>
                                        <div class="col-md-12">
                                            <input type="text" name="weight"
                                                   value="{{ $huati->weight }}"
                                                   class="form-control form-control-line" required>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-2 col-sm-4 form-group bt-switch">
                                    <div class="m-b-30">
                                        <label class="col-md-12">是否推荐</label>
                                        <div class="col-md-12">
                                            <input type="checkbox" data-on-color="success"
                                                   data-off-color="info"
                                                   @if(intval($huati->hot) === App\Huati::HOT_YES) checked
                                                   @endif
                                                   name="hot"
                                                   data-on-text="是"
                                                   data-off-text="否">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-2 col-md-4">
                                    <label class="control-label">父级话题</label>
                                    <div class="example">
                                        <select style="height: 38px" name="p_id">
                                            @foreach(App\HuatiParent::Huatis() as $value)
                                                <option value="{{ $value->id }}"
                                                        @if($huati->p_id === $value->id) selected @endif>{{ $value->title }}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>

                            </div>
                            <div class="row">
                                <div class="col-lg-4 col-md-4">
                                    <div class="form-group">
                                        <label class="col-md-12">展示图</label>
                                        <div class="col-md-12">
                                            <div class="form-group ">
                                                <input type="file" id="input-file-now-custom-3" class="dropify"
                                                       name="pic"
                                                       data-default-file="{{ $huati->pic }}"
                                                       data-height="200px"
                                                />
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-4 col-md-4">
                                    <div class="form-group">
                                        <label class="col-md-12">背景图片</label>
                                        <div class="col-md-12">
                                            <div class="form-group ">
                                                <input type="file" id="input-file-now-custom-3" class="dropify"
                                                       name="bg_pic"
                                                       data-default-file="{{ $huati->bg_pic }}"
                                                       data-height="200px"
                                                />
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <textarea style="height: 150px; width: 100%;overflow:auto;"
                                          name="introduce">{{ $huati->introduce }}</textarea>
                            </div>

                            <div class="form-group">
                                <a class="fcbtn btn btn-success btn-outline btn-1e waves-effect"
                                   href="/huati/huatiList">返回列表
                                </a>
                                <button class="fcbtn btn btn-success btn-outline btn-1e waves-effect">修改
                                </button>
                                {!! csrf_field() !!}
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

@endsection
@section('js')
    @parent
    <!-- icheck -->
    <script src="{{ asset('plugins/bower_components/icheck/icheck.min.js') }}"></script>
    <script src="{{ asset('plugins/bower_components/icheck/icheck.init.js') }}"></script>
    <script src="{{ asset('js/jasny-bootstrap.js') }}"></script>
    <!-- jQuery file upload -->
    <script src="{{ asset('plugins/bower_components/dropify/dist/js/dropify.min.js') }}"></script>
    <script src="{{ asset('plugins/bower_components/summernote/dist/summernote.min.js') }}"></script>
    <script>
        $(document).ready(function () {
            // Basic
            $('.dropify').dropify();
        });
    </script>
    <script src="{{ asset('plugins/bower_components/bootstrap-select/bootstrap-select.min.js') }}"
            type="text/javascript"></script>
    <!-- bt-switch -->
    <script src="{{ asset('plugins/bower_components/bootstrap-switch/bootstrap-switch.min.js') }}"></script>
    <script type="text/javascript">

        jQuery(document).ready(function () {

            $('.summernote').summernote({
                height: 350, // set editor height
                minHeight: null, // set minimum height of editor
                maxHeight: null, // set maximum height of editor
                focus: false, // set focus to editable area after initializing summernote$('.summernote').summernote({
                toolbar: [
                    // [groupName, [list of button]]
                    ['style', ['bold', 'italic', 'underline', 'clear']],
                    ['fontsize', ['fontsize']],
                    ['fontname', ['fontname']],
                    ['color', ['color']],
                    ['para', ['ul', 'ol', 'paragraph']],
                    ['height', ['height']],
                    ['insert', ['link', 'picture', 'video']],
                    ['view', ['fullscreen', 'codeview', 'help']]
                ],
                lang: 'zh-CN',
                // placeholder: '内容',
                dialogsFade: true,
            });

            $('.inline-editor').summernote({
                airMode: true
            });

        });

        $(".bt-switch input[type='checkbox'], .bt-switch input[type='radio']").bootstrapSwitch();
        var radioswitch = function () {
            var bt = function () {
                $(".radio-switch").on("switch-change", function () {
                    $(".radio-switch").bootstrapSwitch("toggleRadioState")
                }),
                    $(".radio-switch").on("switch-change", function () {
                        $(".radio-switch").bootstrapSwitch("toggleRadioStateAllowUncheck")
                    }),
                    $(".radio-switch").on("switch-change", function () {
                        $(".radio-switch").bootstrapSwitch("toggleRadioStateAllowUncheck", !1)
                    })
            };
            return {
                init: function () {
                    bt()
                }
            }
        }();
        $(document).ready(function () {
            radioswitch.init()
        });


        $(document).ready(function () {
            var hidden = $('#hidden').val();
            if (hidden === 'hidden') {
                if ($('#status').val() == 1) {
                    toastsuccess($('#message').val());
                } else {
                    toasterror($('#message').val());
                }
            }
        });

    </script>
@endsection